package com.hw.dagl.controller;

import com.hw.dagl.model.Vehicle;
import com.hw.dagl.service.VehicleService;
import com.hw.dao.utils.ControllerUtil;
import com.hw.dao.utils.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 机动车基本信息
 */
@Controller
public class VehicleInfoController extends BaseController{

    @Resource
    private VehicleService vehicleService;

    /**
	 * 跳转到机动车基本信息查询页面
	 */
    @RequestMapping(method= RequestMethod.GET)
    public String vehicle(HttpServletResponse response){
        return "vehicle/vehicleList";
    }
    /**
     * 查询机动车基本信息
     * @param response
     * @param request
     * @param info
     */
    @RequestMapping(method=RequestMethod.POST)
    public void findJdcxx(HttpServletResponse response,HttpServletRequest request,Page<Vehicle> pages,Vehicle info,String sltbz){
        ControllerUtil.renderJson(response, vehicleService.findJdcxx(pages,info,sltbz), "encoding:UTF-8", "no-cache:false");
    }

    /**
     * 根据机动车序号查询机动车基本信息
     * @param response
     * @param request
     * @param info
     */
    @RequestMapping(method=RequestMethod.GET)
    public ModelAndView findJdcxxByXh(HttpServletResponse response,HttpServletRequest request,Vehicle info){
        ModelAndView mv = new ModelAndView("vehicle/vehicleInfo");
        Vehicle veh = vehicleService.findJdcxxByXh(info);
        mv.addObject("jdcxx",veh);
        return mv;
    }
}
